package com.weipai.springboot.module.dao.impl;

import com.sun.org.apache.bcel.internal.generic.RETURN;
import com.weipai.springboot.model.Artisan;
import com.weipai.springboot.model.ArtisanEarings;
import com.weipai.springboot.model.Customer;
import com.weipai.springboot.module.dao.ArtisanDao;
import com.weipai.springboot.module.mapper.ArtisanEaringsMapper;
import com.weipai.springboot.module.mapper.ArtisanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/28 10:36
 */
@Repository
public class ArtisanDaoImpl implements ArtisanDao {

    @Autowired
    private ArtisanMapper artisanMapper;
    @Autowired
    private ArtisanEaringsMapper earingsMapper;

    @Override
    public int insert(Artisan artisan) {
        return artisanMapper.insertSelective(artisan);
    }

    @Override
    public List<Map<String, Object>> selectAllByDel(int del, String search, String sort, String way, String isAudit,String demandCategoryId) {
        return artisanMapper.selectAllByDel(del, search, sort, way, isAudit,demandCategoryId);
    }

    @Override
    public Artisan getArtisanById(String id) {
        return artisanMapper.getArtisanById(id);
    }

    @Override
    public int updateDel(String id) {
        return artisanMapper.updateDel(id);
    }

    @Override
    public int batchDeleteById(String[] id) {
        return artisanMapper.batchDeleteById(id);
    }

    @Override
    public int updateStatus(String id, Integer status) {
        return artisanMapper.updateStatus(id, status);
    }

    @Override
    public int updateByPrimaryKey(Artisan artisan) {
        return artisanMapper.updateByPrimaryKeySelective(artisan);
    }

    //首页推荐技工
    @Override
    public List<Map<String, Object>> recommendArtisan(String city) {
        return artisanMapper.recommendArtisan(city);
    }

    //根据用户id查询技工信息
    @Override
    public Artisan getArtisanByCustomerId(String customerId) {
        return artisanMapper.getArtisanByCustomerId(customerId);
    }

    @Override
    public Artisan getArtisanByMobile(String mobile) {
        return artisanMapper.getArtisanByMobile(mobile);
    }

    @Override
    public int changeIsAudit(String id, Integer isAudit) {
        return artisanMapper.changeIsAudit(id, isAudit);
    }

    @Override
    public int saveArtisanEarings(ArtisanEarings earings) {
        return earingsMapper.insertSelective(earings);
    }

    @Override
    public List<Map<String, Object>> getArtisanEaringsByArtisanId(String artisanId, Integer start, Integer size, String startTime, String endTime) {
        return earingsMapper.getArtisanEaringsByArtisanId(artisanId, start, size, startTime, endTime);
    }

    @Override
    public Integer getArtisanEaringsByArtisanIdAmount(String artisanId, String startTime, String endTime) {
        return earingsMapper.getArtisanEaringsByArtisanIdAmount(artisanId, startTime, endTime);
    }

    @Override
    public Integer getArtisanMoney(String artisanId, String startTime, String endTime) {
        return earingsMapper.getArtisanMoney(artisanId, startTime, endTime);
    }

    @Override
    public List<Map<String, Object>> getCanCashMoney() {
        return earingsMapper.getCanCashMoney();
    }

    @Override
    public int updateStatus() {
        return earingsMapper.updateStatus();
    }

    @Override
    public List<Map<String, Object>> getMyIncomesList(String artisanId) {
        return earingsMapper.getMyIncomesList(artisanId);
    }
}
